package com.xubeizhi.controller;

import com.xubeizhi.common.Result;
import com.xubeizhi.entity.User;
import com.xubeizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/user")
@CrossOrigin
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(User user){
        return userService.login(user);
    }

    @PostMapping("/register")
    public Result save(User user){
        return userService.register(user);
    }

    @GetMapping("/userInfo")
    public Result getUserInfo(Integer id){
        return userService.getUserInfo(id);
    }

    @PostMapping("/update")
    public Result updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }

    @GetMapping("/users")
    public Result getEmail(){
        return userService.getEmail();
    }


}
